<?php
class Basic_Parser implements Parser {
    private $_view;
    private $_variables;
    
    function __construct( $filename ) {
        if( file_exists( VIEWS_PATH . $filename ) ) {
            $this -> _view = VIEWS_PATH . $filename;
        }else
            throw new FrameException( 'Nie ma pliku widoku o nazwie ' . $filename );
    }
    
    function assign( $key, $value ) {
        $this -> _variables[ $key ] = $value;
        return $this;
    }
    
    function render( $return = false ) {
        ob_start();
        extract( $this -> _variables );
        include $this -> _view;
        $result = ob_get_contents();
        ob_end_clean();
        if( $return )
            return $result;
        echo $result;
    }
}